List Provider - Sample Code

List Provider - Sample Code

The sample ListProvider in this example does the following:

 

The sample code demonstrates

 

The sample code provides functionality for requirements such as:

 

Setup

This sample code needs the following to run:

 

About the ExtFrameworkListProvider Rulebase

The rules are not relevant for this sample, it is the attributes that the List Provider needs to provide list options for

The attributes relevant to this example:

Global

 

About the SQL database

AU_STATES

ID

STATE_SHORTNAME

STATE_FULLNAME

 

POLITICAL_ALIGNMENTS

ID

PA_NAME

 

About the Derby List Provider plugin

To setup this scenario:

  1. Create the SQL Database using create_db.sql which can be found in examples\interview-engine\derby-list-provider\src; for the .NET version, first create the ListProvider database using a tool such as MS SQL Server Management Studio Express.
  2. Copy the rulebase .zip file (ExtFrameworkListProvider.zip) from examples\rulebases\compiled to the rulebase folder in Web Determinations (for example, <webroot>\WEB-INF\classes\rulebases)

  3. Copy and install the DerbyListProvider.jar file (located in examples\interview-engine\derby-list-provider) into Web Determinations; for more information, refer to Create a Plugin.
  4. For the Java version, ensure that DERBY is run in network server mode and copy the DERBY libraries to the library folder in Web Determinations (for example, <webroot>\WEB-INF\lib)
  5. For the .NET version, ensure that SQL Server is running and the ASPNET user account has access to the database.

  6. Run a Web Determinations Interview

Note:

If you need to modify the database connection details or you need class files for your specific database implementation, then you will need to edit the source code, recompile and create the JAR or DLL.

How the DerbyListProvider works

The DerbyListProvider is always called when a List input control is displayed during the Web Determinations Interview. The DerbyListProvider allows the Web Determinations to use the default list items on the List input control (default list items - the list of values provided by the rule author) unless the Attribute associated to the List input control is 'states' or 'political_alignment'. The DerbyListProvider returns a 'null' object to let the Web Determinations know to use the default list items.

If the Attribute of the List input control is 'states' or 'political_alignment', DerbyListProvider accesses the DERBY database, access either the AU_STATES or POLITICAL_ALIGNMENTS table (depending on the Attribute), and gets the list items. It then constructs a List of ListOptions from the data retrieved. The DerbyListProvider returns the list of ListOptions, which tells Web Determinations that it should use this list as the items in the List input control instead of the default list.

Source Code

To view the source code for the sample, refer to examples\interview-engine\derby-list-provider in the Java runtime zip file or examples\interview-engine\list-provider in the .NET runtime zip file.